<template>
  <div class="header">
    <div class="head">
      <img src="../assets/login.png" alt="">
      <div class="userinfo" v-if="name != 'Login'">
        <i class="el-icon-user-solid" @click="put()"></i>
        <span>{{username}}</span>
        <ul>
          <li @click="change()">账号管理</li>
          <li @click="logout()">退出登录</li>
        </ul>
      </div>
      <div class="phone" v-else>
        <p>咨询电话：<em>400-1886-529</em></p>
      </div>
    </div>
  </div>
</template>

<script>
import axios from 'axios'
export default {
  name:'header',
  data () {
    return {
      username:'',
      name:'',
      token:'',
    }
  },
  created () {
    this.username = localStorage.getItem('username')
    this.name = this.$route.name
  },
  methods: {

    logout(){
      axios
      .post("http://47.108.58.38/tk/login/out")
      .then(res =>{
          this.$router.push('/login')
          this.$message.success("退出成功！")
      })
      .catch(err =>{
        this.$message.error("退出失败！")
      })
    },
    change(){
      alert("未做！")
    }
  }
}
</script>

<style scoped lang="less">

@media screen and(max-width:1800px){
  .header{
  width: 100%;
  height: 50px;
  background-color: #fff;
  .head{
    width: 1200px;
    height: 30px;
    padding: 10px 20px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    .userinfo {
      cursor: pointer;
      height: 50px;
      position: relative;
      width: 110px;
      display: flex;
          justify-content: center;
          align-items: center;
      i{
        font-size: 20px;
        color: #409eff;
      }
      span{
        font-size: 18px;
        color: #409eff;
      }
      ul{
        width: 110px;
        min-height: 70px;
        background: #ecf5ff;
        padding: 0;
        position: absolute;
        top: 34px;
        left: 0;
        display: none;
        z-index: 2;
        li{
          width: 100px;
          height: 30px;
          display: flex;
          justify-content: center;
          align-items: center;
          color: #409eff;
          font-size: 14px;
          padding: 5px 10px;
          box-sizing: border-box;
          margin-left: 5px;
        }
        li:hover{
          background: #409eff;
          color: #fff;
        }
      }
    }
    .userinfo:hover ul{
      display: block;
    }
    .phone{
      height: 30px;
      display: flex;
      align-items: center;
      p{
        font-size: 14px;
        em{
          font-size: 20px;
          color: #409eff;
        }
      }
    }
  }
}
}

@media screen and(max-width: 800px) and (min-width: 400px){

   .header{
  width: 100%;
  height: 50px;
  background-color: #fff;
  .head{
    width: 350px;
    height: 15px;
    padding: 10px 20px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    img{
      width: 100px;
    }
    .userinfo {
      cursor: pointer;
      height: 50px;
      position: relative;
      width: 110px;
      display: flex;
          justify-content: center;
          align-items: center;
      i{
        font-size: 12px;
        color: #409eff;
      }
      span{
        font-size: 12px;
        color: #409eff;
      }
      ul{
        width: 110px;
        min-height: 70px;
        background: #ecf5ff;
        padding: 0;
        position: absolute;
        top: 34px;
        left: 0;
        display: none;
        z-index: 2;
        li{
          width: 100px;
          height: 30px;
          display: flex;
          justify-content: center;
          align-items: center;
          color: #409eff;
          font-size: 14px;
          padding: 5px 10px;
          box-sizing: border-box;
          margin-left: 5px;
        }
        li:hover{
          background: #409eff;
          color: #fff;
        }
      }
    }
    .userinfo:hover ul{
      display: block;
    }
    .phone{
      height: 20px;
      display: flex;
      align-items: center;
      p{
        font-size: 12px;
        margin-right: 60px;
        em{
          font-size: 12px;
          color: #409eff;
        }
      }
    }
  }
}
}
@media screen and(max-width: 400px) and (min-width: 350px){
   .header{
  width: 100%;
  height: 50px;
  background-color: #fff;
  .head{
    width: 350px;
    height: 15px;
    padding: 10px 20px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    img{
      width: 100px;
    }
    .userinfo {
      cursor: pointer;
      height: 50px;
      position: relative;
      width: 110px;
      display: flex;
          justify-content: center;
          align-items: center;
      i{
        font-size: 12px;
        color: #409eff;
      }
      span{
        font-size: 12px;
        color: #409eff;
      }
      ul{
        width: 110px;
        min-height: 70px;
        background: #ecf5ff;
        padding: 0;
        position: absolute;
        top: 34px;
        left: 0;
        display: none;
        z-index: 2;
        li{
          width: 100px;
          height: 30px;
          display: flex;
          justify-content: center;
          align-items: center;
          color: #409eff;
          font-size: 14px;
          padding: 5px 10px;
          box-sizing: border-box;
          margin-left: 5px;
        }
        li:hover{
          background: #409eff;
          color: #fff;
        }
      }
    }
    .userinfo:hover ul{
      display: block;
    }
    .phone{
      height: 20px;
      display: flex;
      align-items: center;
      p{
        font-size: 12px;
        margin-right: 60px;
        em{
          font-size: 12px;
          color: #409eff;
        }
      }
    }
  }
}
}
@media screen and(max-width: 350px){
  .header{
  width: 100%;
  height: 50px;
  background-color: #fff;
  .head{
    width: 350px;
    height: 15px;
    padding: 10px 20px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    img{
      width: 100px;
    }
    .userinfo {
      cursor: pointer;
      height: 50px;
      position: relative;
      width: 110px;
      display: flex;
          justify-content: center;
          align-items: center;
      i{
        font-size: 12px;
        color: #409eff;
      }
      span{
        font-size: 12px;
        color: #409eff;
      }
      ul{
        width: 110px;
        min-height: 70px;
        background: #ecf5ff;
        padding: 0;
        position: absolute;
        top: 34px;
        left: 0;
        display: none;
        z-index: 2;
        li{
          width: 100px;
          height: 30px;
          display: flex;
          justify-content: center;
          align-items: center;
          color: #409eff;
          font-size: 14px;
          padding: 5px 10px;
          box-sizing: border-box;
          margin-left: 5px;
        }
        li:hover{
          background: #409eff;
          color: #fff;
        }
      }
    }
    .userinfo:hover ul{
      display: block;
    }
    .phone{
      height: 20px;
      display: flex;
      align-items: center;
      p{
        font-size: 12px;
        margin-right: 60px;
        em{
          font-size: 12px;
          color: #409eff;
        }
      }
    }
  }
}
}

</style>
